import java.util.Scanner;

class Node{
    public char val;
    public Node left;
    public Node right;
    public Node(char val) {
        this.val = val;
    }
}
public class MyTree {
    static int i=0;
    public static Node createTree(String str){
        if(str==null){
            return null;
        }
        char ch=str.charAt(i);
        Node root=null;
        if(ch!='#'){
            root=new Node(ch);
            i++;
            root.left=createTree(str);
            root.right=createTree(str);
        }else{
            i++;
        }
        return root;
    }
    public static void inorder(Node root){
        if(root==null){
            return;
        }
        inorder(root.left);
        System.out.print(root.val+" ");
        inorder(root.right);
    }
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        while(scan.hasNext()){
            String str=scan.nextLine();
            Node root=createTree(str);
            inorder(root);
        }
    }
}
